var request;
function searchForCourse(){
	if (undefined!=request){
		alert('blat');
		request.abort();
	}
	request = new XMLHttpRequest();
	var input = document.getElementById('searchField').value.split(",");
	var searchParams ="";
	for (var i=0;i<input.length;i++){
		searchParams+= '&param'+i+'='+input[i];
	}
	request.open("GET",encodeURI("/shahalanddavid/SearchCourse?numofparams=" + input.length + searchParams), true);
	request.onreadystatechange = changeSearchOutput;
	request.send(null);
}
	
	
function changeSearchOutput(){
	if (request.readyState < 4){
		document.getElementById('searchResults').innerHTML='Loading...';
		return;
	}
	else if (request.readyState == 4 && request.status == 200){
		document.getElementById('searchResults').innerHTML=request.responseText;
		request = undefined;
		return;
	}
	else{
		document.getElementById('searchResults').innerHTML='<b>Server Sucks</b>';
		request = undefined;
		return;
	}
}